package com.jisc.adaptor.datasources;

import java.util.List;
import com.jisc.adaptor.datasources.util.CSVHandler;
import com.jisc.adaptor.datasources.util.SpreadsheetHandler;

public class CSVReader {
	public Student getStudentRecord(String studentId,String path) throws Exception {
		SpreadsheetHandler spreadsheet = new CSVHandler(
				path,
				',', true);
		List<List<String>> students = spreadsheet.getRowsWithValues(
				new String[] { "StudentID" }, new String[] { studentId }, "AND");
		List<String> studentAttribute = students.get(0);
		Student student = new Student();
		
		student.setAddressCity((String) studentAttribute.get(7));
		student.setAddressCounty((String) studentAttribute.get(8));
		student.setAddressNatCode((String) studentAttribute.get(9));
		student.setAddressStreetLine1((String) studentAttribute.get(4));
		student.setAddressStreetLine2((String) studentAttribute.get(5));
		student.setAddressStreetLine3((String) studentAttribute.get(6));
		student.setDob((String) studentAttribute.get(0));
		student.setFirstName((String) studentAttribute.get(1));
		student.setHesaReference((String) studentAttribute.get(3));
		student.setStudentID((String) studentAttribute.get(0));
		student.setSurName((String) studentAttribute.get(2));
		
		return student;
	}

}
